﻿/*
 *  RacerLib - XNA Racing Game Level and Tile Management Library
 * 
 *  Copyright (C) 2009 Sebastian Schäfer
 *  
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License 
 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Linq;
using System.Text;

namespace RacerEditorWIN
{
    /// <summary>
    /// A String Redirection so the console output can be inserted into a RichTextBox
    /// </summary>
    public class StringRedir : StringWriter
    {
        private RichTextBox outBox;

        /// <summary>
        /// Create a new Redirection
        /// </summary>
        /// <param name="textBox">Output</param>
        public StringRedir(ref RichTextBox textBox)
        {
            outBox = textBox;
        }

        /// <summary>
        /// Write a line by appending a LineBreak
        /// </summary>
        /// <param name="txt">Text to be written</param>
        public override void WriteLine(string txt)
        {
            outBox.Text += txt + "\n";
            outBox.Refresh();
        }
    }
}
